<template>
  <div class="app-container">

    <u-page title="权益管理">

      <u-filtered>
        <el-form ref="listQuery" :inline="true" :model="listQuery" class="search-form">
          <el-form-item label="订单号" prop="orderNo">
            <el-input v-model="listQuery.orderNo" placeholder="订单号" clearable />
          </el-form-item>
          <el-form-item label="卡号" prop="memberId">
            <el-input v-model="listQuery.memberId" placeholder="卡号" clearable />
          </el-form-item>
          <el-form-item label="车牌" prop="plateNo">
            <el-input v-model="listQuery.plateNo" placeholder="车牌" clearable />
          </el-form-item>
          <el-form-item label="操作时间">
            <u-date-time-picker v-model="searchDate" value-format="yyyy-MM-dd HH:mm:ss" @change="changeSearchDate" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="hdlFilter">搜索</el-button>
          </el-form-item>
          <el-form-item>
            <el-dropdown>
              <el-button type="primary">
                批量操作<i class="el-icon-arrow-down el-icon--right" />
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item :disabled="selectData.length===0" @click.native="hdlDel">批量删除</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-form-item>
        </el-form>
      </u-filtered>

      <u-table
        :data="list"
        :loading="listLoading"
        :options="listOptions"
        :columns="columns"
        :pagination.sync="listQuery"
        :fetch="hdlList"
        @selection-change="hdlSelectChange"
      >
        <template v-slot:right>
          <el-table-column label="操作" align="center" fixed="right">
            <template slot-scope="{ row }">
              <el-button type="text" @click="hdlDelete(row.id, row.memberId)">删除</el-button>
            </template>
          </el-table-column>
        </template>
      </u-table>

    </u-page>

  </div>
</template>
<script>
export default {
  data() {
    return {
      api: this.$u.api.PluginsParkingBenefit,
      // 表格
      columns: [
        {
          prop: 'orderNo',
          label: '订单号'
        },
        {
          prop: 'memberId',
          label: '卡号'
        },
        {
          prop: 'plateNo',
          label: '车牌'
        },
        {
          prop: 'createdAt',
          label: '操作时间',
          timestamp: true
        }
      ],

      list: [],
      listLoading: true,
      listOptions: {
        mutiSelect: true, // boolean 是否多选
        stripe: true // boolean 斑马纹
      },
      listQuery: {
        pageNumber: 1,
        pageSize: 10,
        totalCount: 1,
      },

      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: '编辑权益',
        create: '新增权益'
      },
      dataForm: {},
      rules: {
        spaceNo: [
          { required: true, message: '请输入车位编号', trigger: ['blur'] }
        ]
      },
      // 删除选中数据
      selectData: [],
      newForm: {
        status: 1
      }
    }
  },
  created() {
    this.hdlList()
  }
}
</script>
